#!/usr/bin/make -f
# Made with the aid of debmake, by Christoph Lameter,
# based on the sample debian/rules file for GNU hello by Ian Jackson.

package=fwbuilder
pkgver=2.1.17

prefix := /usr

SHELL = /bin/bash
CC = gcc
CPP = cpp
CXX = g++
CFLAGS := -O2 
CXXFLAGS := -O2 
IE := install -m755 -s
ID := install -m644
CHMOD := chmod

# disable switch -s in install.sh
export STRIPPROG := true

# Some special build options
ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
  CFLAGS += -g
  CXXFLAGS += -g
  ifneq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
    IE := install -m755
  endif
endif

# the dbs rules
TAR_DIR := $(package)-$(pkgver)

include /usr/share/dbs/dbs-build.mk

# dpkg-arch rules
ifeq (,$(DEB_BUILD_GNU_TYPE))
  include /usr/share/dbs/dpkg-arch.mk
endif

configure_args := --prefix=${prefix} 				\
	--mandir=${prefix}/share/man				\
	--infodir=${prefix}/share/info				\
	--with-iconsdir=${prefix}/share/pixmaps/fwbuilder	\
	--with-docdir=${prefix}/share/doc/fwbuilder		\
	--with-templatedir=${prefix}/share/fwbuilder		\
	--localstatedir=/var					\
	--sharedstatedir=/var					\
	--sysconfdir=/etc

ifneq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE))
  configure_args += --enable-x-compile --build=$(DEB_BUILD_GNU_TYPE)
endif

built		=	$(STAMP_DIR)/build
installed	=	$(STAMP_DIR)/install
configed	=	$(STAMP_DIR)/config

configure: setup $(configed)
$(configed): 
	dh_testdir
	./autogen.sh $(configure_args)
	touch $@

build: configure $(built)
$(built): 
	$(MAKE)
	touch $@

install: build $(installed)
$(installed): 
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs
	dh_installmenu
	$(MAKE) install INSTALL_ROOT=`pwd`/debian/tmp
	touch $@

clean:
	dh_testdir
	dh_clean
	rm -rf $(STAMP_DIR) $(SOURCE_DIR)
	rm -f debian/files.saved debian/files
	rm -f debian/*.dirs debian/*.files
	rm -f debian/*.undocumented debian/*.doc-base
	rm -f debian/dirs debian/install
	rm -f $$(find . -type l) $$(find . -name "*~" -o -name "*.o")
	rm -rf debian/$(package) debian/$(package)-{doc,dev}
	rm -f debian/manpages debian/menu
	rm -rf debian/{files*,*substvars*,*.gz} core
	rm -f $$(find * -name "*.orig")

binary-indep: checkroot build install
	dh_testdir
	dh_testroot
	dh_install --list-missing -i
	dh_installdocs -i
	dh_installexamples -i
	dh_installchangelogs -i debian/tmp/usr/share/doc/fwbuilder/ChangeLog
	dh_link -i
	dh_compress -i 
	dh_fixperms -i
	dh_installdeb -i
	dh_gencontrol -i
	dh_md5sums -i
	dh_fixperms -i
	dh_builddeb -i

binary-arch: checkroot build install
	dh_testdir
	dh_testroot
	dh_install --list-missing -a
	dh_installdocs -a
	dh_installmenu -a
	dh_installman -a
	dh_installexamples -a
	dh_installchangelogs -a	debian/tmp/usr/share/doc/fwbuilder/ChangeLog
	dh_link -a
	dh_compress -a 
	dh_fixperms -a
	dh_installdeb -a
	dh_shlibdeps -a
	dh_gencontrol -a
	dh_strip -a
	dh_md5sums -a
	dh_fixperms -a
	dh_builddeb -a

binary: binary-indep binary-arch

.PHONY: binary binary-arch binary-indep clean checkroot
